package dynamicProgramming.review6_1;

public class AllBagProblem {


    public  static   void test(){
        int[] weight = {1, 3, 4};
        int[] value = {15, 20, 30};
        int bagWeight = 4;
        int []dp=new int[bagWeight+1];

        for (int i = 0; i < weight.length; i++) { //  CKG TODO 2023/6/1: 先遍历物品

            for (int j = weight[i]; j <=bagWeight ; j++) {//  CKG TODO 2023/6/1: 再遍历背包
                //  CKG TODO 2023/6/1: 这里可以重复拿了
                dp[j]=Math.max(dp[j],dp[j-weight[i]]+value[i]);
            }

        }
        for (int a:dp
             ) {
            System.out.println(a+"");

        }

    }

    public static void main(String[] args) {

        AllBagProblem.test();
    }
}
